package com.example.mypra1.adapter;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;

import com.example.mypra1.R;
import com.szysky.customize.siv.SImageView;

public class MyGridAdapter extends BaseAdapter {

    private String[] urls; //图片路径
    private Context context;
    private LayoutInflater inflater;

    public MyGridAdapter(String[] urls, Context context) {//适配器
        super();
        this.urls = urls;
        this.context = context;
        this.inflater = LayoutInflater.from(context);
    }

    @Override
    public int getCount() {
        return urls.length;
    }

    @Override
    public Object getItem(int position) {
        return urls[position];
    }

    @Override
    public long getItemId(int position) {
        return position;
    }

    @Override
    public View getView(int position, View v, ViewGroup parent) {
        v = inflater.inflate(R.layout.item_grid, null);
        SImageView tv=  (SImageView) v.findViewById(R.id.single_img);
        tv.setImageUrls(urls[position]);
        return v;
    }
}
